package com.langchain4j.core.flow.engine;

import com.langchain4j.core.flow.node.FlowNode;
import lombok.Data;
import lombok.Builder;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * 流程定义
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class FlowDefinition {
    
    /**
     * 流程ID
     */
    private String id;
    
    /**
     * 流程名称
     */
    private String name;
    
    /**
     * 流程描述
     */
    private String description;
    
    /**
     * 流程版本
     */
    private Integer version;
    
    /**
     * 流程状态
     */
    private FlowStatus status;
    
    /**
     * 开始节点
     */
    private FlowNode startNode;
    
    /**
     * 所有节点
     */
    private List<FlowNode> nodes;
    
    /**
     * 节点连接关系
     */
    private List<FlowConnection> connections;
    
    /**
     * 输入参数定义
     */
    private Map<String, Object> inputSchema;
    
    /**
     * 输出参数定义
     */
    private Map<String, Object> outputSchema;
    
    /**
     * 创建者
     */
    private String createdBy;
    
    /**
     * 创建时间
     */
    private LocalDateTime createdAt;
    
    /**
     * 更新时间
     */
    private LocalDateTime updatedAt;
    
    /**
     * 流程状态枚举
     */
    public enum FlowStatus {
        DRAFT("草稿"),
        PUBLISHED("已发布"),
        ARCHIVED("已归档");
        
        private final String description;
        
        FlowStatus(String description) {
            this.description = description;
        }
        
        public String getDescription() {
            return description;
        }
    }
    
    /**
     * 节点连接
     */
    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class FlowConnection {
        /**
         * 源节点ID
         */
        private String sourceNodeId;
        
        /**
         * 目标节点ID
         */
        private String targetNodeId;
        
        /**
         * 连接条件
         */
        private String condition;
        
        /**
         * 连接类型
         */
        private ConnectionType type;
        
        /**
         * 连接类型枚举
         */
        public enum ConnectionType {
            SEQUENCE("顺序连接"),
            CONDITION("条件连接"),
            PARALLEL("并行连接");
            
            private final String description;
            
            ConnectionType(String description) {
                this.description = description;
            }
            
            public String getDescription() {
                return description;
            }
        }
    }
} 